struct VertexInput {
    @location(0) position: vec2f,
};

struct VertexOutput {
    @builtin(position) clip_position: vec4f,
    @location(0) uv: vec2f,
};

// 变换矩阵 - 绑定组0
@group(0) @binding(0) var<uniform> model: mat4x4f;
@group(0) @binding(1) var<uniform> view: mat4x4f;
@group(0) @binding(2) var<uniform> proj: mat4x4f;

// 背景颜色 - 绑定组1
@group(1) @binding(0) var<uniform> background_color: vec4f;

@vertex
fn vs_main(
    @location(0) position: vec2f,
) -> VertexOutput {
    var out: VertexOutput;
    
    // 将位置从[-1,1]映射到[0,1]的UV坐标
    out.uv = position * 0.5 + 0.5;
    
    // 简化变换：直接使用投影矩阵，忽略模型和视图变换
    // 因为全屏四边形已经在NDC坐标中
    out.clip_position = vec4f(position, 0.0, 1.0);
    
    return out;
}

// 简单的梯度片元着色器
@fragment
fn fs_main(in: VertexOutput) -> @location(0) vec4f {
    let base_color = background_color.rgb;
    
    // 简单的垂直梯度：从顶部到底部渐变
    let gradient_factor = in.uv.y; // 0.0在顶部，1.0在底部
    
    // 顶部较亮，底部较暗
    let top_brightness = 1.2;
     let bottom_brightness = 0.8;
    let brightness = mix(bottom_brightness, top_brightness, gradient_factor);
    
    // 应用梯度效果
    let final_color = base_color * brightness;
        
    return vec4f(final_color, background_color.a);
}